package 剑指offer_leetcode;

/**
 * JZ14剪绳子
 */
public class 剑指Offer14_I_剪绳子 {
    public int cuttingRope(int n) {
        if(n<=3)
            return n-1;
        int res = n / 3;
        int mod = n %3;
        if(mod==0)
            return (int)Math.pow(3,res);
        else if(mod==1)
            return (int) Math.pow(3,res-1) * 4;
        else
            return  (int) Math.pow(3,res) * 2;
    }
}
